﻿/*开关按钮动画效果
 * 时间 2024-01-16
 */
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#pragma execution_character_set("utf-8")
#include <QMainWindow>
class QPropertyAnimation;
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
    void func();
protected:
    void paintEvent(QPaintEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void resizeEvent(QResizeEvent *event) override;
private:
    Ui::MainWindow *ui;
    bool isOff = true;//默认值为关的状态
    bool isOffBrush = true;
    QBrush offBgBrush = Qt::black;
    QBrush offIndicatorBrush = Qt::red;
    QBrush onBgBrush = Qt::blue;
    QBrush onIndicatorBrush = Qt::green;
    QString offText = "OFF";
    QString onText = "ON";
    QPropertyAnimation* animation = nullptr;
    QPropertyAnimation* animation_1 = nullptr;
    int movePoint = 0;
    int movePoint_1 = 0;
};
#endif // MAINWINDOW_H
